<template>
  <div class="menu">
    <button class="menu-item" @click="changeLang('zh')">中文</button>
    <button class="menu-item" @click="changeLang('en')">English</button>
  </div>

  <div> {{ $t('login.username') }} </div>
</template>


<script setup lang="ts">
import { useI18n } from 'vue-i18n'
const { locale } = useI18n()

const changeLang = (lang: string) => {
  locale.value = lang
  localStorage.setItem('lang', lang)// 持久化，避免刷新页面后重置中英文
}
</script>
